package cn.easybuy.web.pre;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import sun.security.jgss.spi.MechanismFactory;

import cn.easybuy.entity.Product;
import cn.easybuy.service.product.ProductService;
import cn.easybuy.service.product.ProductServiceImpl;
import cn.easybuy.utils.MemcachedUtils;

public class ProductServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public ProductServlet() {
		super();
	}


	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String action = request.getParameter("action");
		if(action.equals("show")){
			String id = request.getParameter("id");
			ProductService ps = new ProductServiceImpl();
			Product product =  ps.findProductById(id);
			request.setAttribute("product", product);
			request.getRequestDispatcher("Product.jsp").forward(request, response);
		}
	}

}
